//
//  ByCellLookDotor.m
//  jinpuyiyuan_ios
//
//  Created by pro on 2017/12/11.
//  Copyright © 2017年 mc. All rights reserved.
//

#import "ByCellLookDotor.h"

@implementation ByCellLookDotor
{
    UIImageView *_icon;
    UILabel     *_nickNameLabel;
    UILabel     *_addressLabel;
    UILabel     *_describeLabel;
}
+ (instancetype)cellWithTableView:(UITableView*)tableView{
    
    static NSString *cellIdentifier = @"ByCellLookDotor";
    ByCellLookDotor *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[self alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSeparatorStyleNone;
        [self createViews];
    }
    return self;
}

- (void)createViews{
    _icon = [[UIImageView alloc] init];
    [self addSubview:_icon];
    
    _nickNameLabel = [[UILabel alloc] init];
    _nickNameLabel.font = FONT(14);
    [self addSubview:_nickNameLabel];
    
    _addressLabel = [[UILabel alloc] init];
    _addressLabel.font = FONT(12);
    _addressLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:_addressLabel];
    
    _describeLabel = [[UILabel alloc] init];
    _describeLabel.font = FONT(12);
    [self addSubview:_describeLabel];
}

- (void)setModel:(ByModelRegistrationDoctor *)model{
    _model = model;
    [_icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(10));
        make.top.equalTo(@(15));
        make.size.mas_equalTo(CGSizeMake(55, 55));
    }];
    _icon.backgroundColor = BY_THEME_COLOR;
    _icon.layer.cornerRadius = 55 / 2;
    
    CGFloat width = [_model.nick_name getSizeOfString:14].width + 10;
    [_nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_icon.mas_right).offset(15);
        make.top.equalTo(@(20));
        make.size.mas_equalTo(CGSizeMake(width, 20));
    }];
    
    [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_nickNameLabel.mas_right);
        make.top.equalTo(@(20));
        make.right.equalTo(@(-10));
        make.height.equalTo(@(20));
    }];
    
    [_describeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_nickNameLabel.mas_bottom).offset(5);
        make.left.equalTo(_nickNameLabel.mas_left);
        make.right.equalTo(@(-10));
        make.height.equalTo(@(15));
    }];
    
    // 测试数据
    _nickNameLabel.text = _model.nick_name;
    _addressLabel.text = _model.address;
    _describeLabel.text = _model.decribeStr;
    
}

@end
